Page({
  data: {
    bgd57: "",
    bgd58: "",
    bgd59: "",
    bgd60: "",
    bgd61: "",
    bgd62: "",
    bgd63: "",
    bgd64: "",
    bgd65: "",
    bgd66: "",
    bgd67: "",
    bgd68: "",
    bgd69: "",
    bgd70: "",
    bgd71: "",
    bgd72: "",
    bgd73: "",
    bgd74: "",
    bgd75: "",
    bgd76: "",
    bgd77: "",
    bgd78: "",
    bgd79: "",
    bgd80: "",
    bgd81: "",
    bgd82: "",
    bgd83: "",
    bgd84: "",
  },
  onLoad: function () {
    console.log("order进来");
    //wx.clearStorage();
    var that = this;
    wx.request({
      url: 'https://www.szz5.com/admin/selectAll',
      method: 'POST',
      data: {},
      success: function (res) {
        console.info("++++++++++=1", JSON.stringify(res));
        var list = res.data;
        console.info("++++++++++=2", JSON.stringify(list));
        if (list != null) {
          for (var index in list) {
            console.info("++++++++++=3", list[index]);
            var bathid = list[index];
            if (bathid == '057') {
              console.info("进来001");
              that.setData({
                bgd57: "red"
              });
            }
            if (bathid == "058") {
              console.info("进来002");
              that.setData({
                bgd58: "red"
              });
            }
            if (bathid == "059") {
              that.setData({
                bgd59: "red"
              });
            }
            if (bathid == "060") {
              that.setData({
                bgd60: "red"
              });
            }
            if (bathid == "061") {
              that.setData({
                bgd61: "red"
              });
            }
            if (bathid == "062") {
              that.setData({
                bgd62: "red"
              });
            }
            if (bathid == "063") {
              that.setData({
                bgd63: "red"
              });
            }
            if (bathid == "064") {
              that.setData({
                bgd36: "red"
              });
            }
            if (bathid == "065") {
              that.setData({
                bgd65: "red"
              });
            }
            if (bathid == "066") {
              that.setData({
                bgd66: "red"
              });
            }
            if (bathid == "067") {
              that.setData({
                bgd67: "red"
              });
            }
            if (bathid == "068") {
              that.setData({
                bgd68: "red"
              });
            }
            if (bathid == "069") {
              that.setData({
                bgd69: "red"
              });
            }
            if (bathid == "070") {
              that.setData({
                bgd70: "red"
              });
            }
            if (bathid == "071") {
              that.setData({
                bgd71: "red"
              });
            }
            if (bathid == "072") {
              that.setData({
                bgd72: "red"
              });
            }
            if (bathid == "073") {
              that.setData({
                bgd73: "red"
              });
            }
            if (bathid == "084") {
              that.setData({
                bg84: "red"
              });
            }
            if (bathid == "074") {
              that.setData({
                bgd74: "red"
              });
            }
            if (bathid == "075") {
              that.setData({
                bgd75: "red"
              });
            }
            if (bathid == "076") {
              that.setData({
                bgd76: "red"
              });
            }
            if (bathid == "077") {
              that.setData({
                bgd77: "red"
              });
            }
            if (bathid == "078") {
              that.setData({
                bgd78: "red"
              });
            }
            if (bathid == "079") {
              that.setData({
                bgd79: "red"
              });
            }
            if (bathid == "080") {
              that.setData({
                bgd80: "red"
              });
            }
            if (bathid == "081") {
              that.setData({
                bgd81: "red"
              });
            }
            if (bathid == "082") {
              that.setData({
                bgd82: "red"
              });
            }
            if (bathid == "083") {
              that.setData({
                bgd83: "red"
              });
            }
          }

          // wx.showToast({
          //   title: '获取数据失败',      
          //   duration: 1500      
          // })
        }
      }
    })
  },
  gotoresult: function (e) {
    var ID = e.currentTarget.id;
    console.log("idd", ID);
    // wx.clearStorage("userInfo");
    var stor = wx.getStorageSync("userInfo");
    var getkey = wx.getStorageSync("key1");
    if (stor == null || stor == "") {
      console.log("stor" + stor);
      wx.showModal({
        title: '提示',
        content: '您没有激活状态，请去激活',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定');

            wx.hideToast()
            wx.switchTab({
              url: '../../login/login'
            })

            console.log('1');
            // return;
          } else if (res.cancel) {
            console.log('用户点击取消');
            return;
          }
        }
      })
    } else if (getkey) {
      wx.showModal({
        title: '提示',
        content: '您已经选择过！',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定');
            return;
          } else if (res.cancel) {
            console.log('用户点击取消');
            return;
          }
        }
      })

    } else {

      wx.request({
        url: 'https://www.szz5.com/admin/byBathId',
        method: 'POST',
        data: { bathId: ID },
        success: function (res) {
          console.info("++++++++++=4", JSON.stringify(res));
          if (res.data == '1') {
            wx.showModal({
              title: '提示',
              content: '此澡位已被预订！',
              success: function (res) {
                if (res.confirm) {
                  console.log('用户点击确定');
                  return;
                } else if (res.cancel) {
                  console.log('用户点击取消');
                  return;
                }
              }
            })
          }
        }

      })
      wx.showModal({
        title: '提示',
        content: '是否预定该位置',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定');
            wx.setStorageSync("keykey", ID);
            wx.navigateTo({
              url: '../../seltime/seltime',
            })
            return;
          } else if (res.cancel) {
            console.log('用户点击取消');
            return;
          }
        }
      })

    }
    // wx.getStorage({
    //   key: 'key',
    //   success: function (res) {
    //     console.log(res.data);
    //     if(res){
    //       console.log(res);

    //       return;
    //     }
    //   },
    // });



  }



})